/**
 * @package com.esun.rabbit2.communicaters.hemai
 * @description 取得合买当前期号通信类
 * @author liugan
 * @data 2012-03-14 13:58
 * 
 */

package com.esun.rabbit2.communicaters.hemai;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Key;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;

/**
 * @classname HemaiGetPeriodCommunicater
 * @description 取得合买当前期号通信类
 * @author liugan
 * @data 2012-03-14 13:58
 * 
 */
public class HemaiGetExpectCommunicater extends ServerCommunicater{


   /**
    * @title strExpect
    * @descripiton 从服务器获得的期号
    */
	private String strExpect = "";
	
	private String serverMsg = "";
	
	
	/**
	 * @title isGetExpectNumberSucceed
	 * @description 从服务器获得彩票合买当前期号
	 * @param lotid 彩种ID
	 * @return 是否成功
	 * @throws ClientProtocolException 
	 * @throws IOException
	 * @throws ParserConfigurationException
	 * @throws SAXException
	 */
	public boolean isGetExpectNumberSucceed(String lotid) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {

		boolean isSucceed;
		//通信参数
		ArrayList<HashMap<String, String>> paramsList = new ArrayList<HashMap<String, String>>();
		paramsList.add(createParamMap(BussinessCode.PASER_MID, BussinessCode.MID_GET_HEMAI_LIST_EXPECT));
		paramsList.add(createParamMap(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));
		paramsList.add(createParamMap(Key.KEY_LOTID, lotid));
		
		
		// 连接服务器获取消息
				super.getServerResponse(paramsList, true);
				setServerMessage(super.getServerMsg());
				if (super.getState() == 100) {
					isSucceed = true;
					setExpect(super.getListResult().get(0).get(Key.KEY_EXPECT));
				} else {
					isSucceed = false;
				}
				return isSucceed;

	}
	
	
	/**
	 * @title createParamMap
	 * @description 构造参数的HashMap
	 * @param name 名
	 * @param value 值
	 * @return 参数HashMap
	 */
	private HashMap<String, String> createParamMap(String name, String value){
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}
	

	private void setServerMessage(String str) {
		serverMsg = str;
	}

	public String getServerMsg() {
		return serverMsg;
	}

	private void setExpect(String str) {
		strExpect = str;
	}

	public String getExpect() {
		return strExpect;
	}
}
